//**************************运算符***************************

public class Test {
    public static void main1(String[] args){
        int a = 10;
        int b = 6;
        System.out.println(a+b);
        System.out.println(a-b);
        System.out.println(a*b);
        System.out.println(a/b);
        System.out.println(a * 1.0 / b);//这里只要有一个是浮点数，那么就会保留小数点

        System.out.println(a + 1.2);//在加之前，int会发生整型提升，转换为double，在进行加法
    }

    public static void main2(String[] args){
        int a = 10;
        int b = ++a;
        int c = a++;
        System.out.println("a = " + a);
        System.out.println("b = " + b);
        System.out.println("c = " + c);
    }

    public static void main3(String[] args) {
        int a = 10;
        int b = 20;

        if (a == b) {
            System.out.println("a == b");
        }
        if (a < b) {
            System.out.println("a < b");
        }
        if (a > b) {
            System.out.println("a > b");
        }
        if (a != b) {
            System.out.println("a ！= b");
        }
    }


    public static void main4(String[] args){
        int a = -10;
        int b = 10;
        //&&会发生短路 --- 当某一个条件不符合 -- 直接返回false
        System.out.println(a > 0 && b > 0);//输出false
        System.out.println(b > 0 && a > 0);//输出flase

        //|| --- 不会发生短路，如果有一个条件符合，那么久不会继续判断后面的条件是否为真
        System.out.println(a > 0 || b > 0);//输出true
        System.out.println(b > 0 || a > 0);//输出true
    }

    public static void main5(String[] args){
        int a = 10;
        int b = 4;
        System.out.println(a & b);
        //a:00000000 00000000 00000000 00001010
        //b:00000000 00000000 00000000 00000100
        //&规则：有0则为0
        //a&b:00000000 00000000 00000000 00000000 = 0

        System.out.println(a | b);
        //a:00000000 00000000 00000000 00001010
        //b:00000000 00000000 00000000 00000100
        //|规则:有1则为1
        //a|b:00000000 00000000 00000000 00001110 = 14

        System.out.println(a ^ b);
        //a:00000000 00000000 00000000 00001010
        //b:00000000 00000000 00000000 00000100
        //^规则：相同则为0
        //a^b:00000000 00000000 00000000 00001110 = 14

        System.out.println(a >> 1);//右移一位
        //a:00000000 00000000 00000000 00001010
        //右移规则：去掉最右边，左边按照符号位补齐
        //a>>1:00000000 00000000 00000000 00000101 = 5

        System.out.println(b << 1);//左移一位
        //b:00000000 00000000 00000000 00000100
        //左移规则：去掉最左边，右边用0补齐
        //b<<1:00000000 00000000 00000000 00001000 = 8
    }

    public static void main(String[] args){
        int a = 10;
        int b = 8;
        int c = a > b? a : b;//三目操作符 --- 如果a>b那么就输出a的值，否则输出b
        System.out.println(c);//输出10
    }




}
